#设计一个类
# class student:
#     name=None
#     age=None
#     home=None
#     sex=None
#
# stu_1=student()
#
# stu_1.name="迪亚菠萝"
# stu_1.age=16
# stu_1.home="意大利"
# stu_1.sex="male"
#
# print(stu_1.name)
from typing import Union


#成员方法的定义和使用
# class demo_stu:
#     name=None
#     age=None
#     home=None
#     gender=None
#
#     def say_hi(self,msg):
#         print(f"你好，我叫{self.name}")
#         print(f"我想问一下{msg}")
#
# stu1=demo_stu()
#
# stu1.name="迪亚菠萝"
# stu1.age=21
# stu1.gender="male"
# stu1.home="意大利"
#
# stu1.say_hi("食堂怎么走")

#闹钟类
# class clock:
#     id=None
#     price=None
#
#     def ring(self):
#         import winsound
#         winsound.Beep(2000,3000)
#
# clock1=clock()
# clock1.id="1001"
# clock1.price=20
# print(f"闹钟的编号是{clock1.id},闹钟的价格是{clock1.price}")
# clock1.ring()

#构造方法测试
# class stu:
#     def __init__(self,name,age,ID):
#         self.name=name
#         self.age=age
#         self.ID=ID
#         print(f"已创建一个学生对象,{name},{age},{ID}")
#
# stu1=stu("迪亚菠萝",21,1001)

# 魔术方法测试
# 字符串方法测试
# class Student_msg:
#     def __init__(self,name,age):
#         self.name=name
#         self.age=age
#
#     def __str__(self):
#        return f"类的对象  name：{self.name},age{self.age}"
# stu=Student_msg("迪亚菠萝",21)
# print(stu)
# print(str(stu))
# 大于小于方法测试
# class Student_age:
#     def __init__(self,age):
#         self.age = age
#     def __lt__(self,other):
#         return self.age<other.age
# stu1=Student_age(21)
# stu2=Student_age(23)
# print(stu1>stu2)
# print(stu1<stu2)
# 大于等于，小于等于方法测试
# class Student_msg:
#     def __init__(self,age):
#         self.age=age
#     def __le__(self,other):
#         return self.age<=other.age
# stu1=Student_msg(21)
# stu2=Student_msg(21)
# print(stu1>=stu2)
# print(stu1<=stu2)
# 相等判断方法
# class Student_msg:
#     def __init__(self,age):
#         self.age = age
#     def __eq__(self,other):
#         return self.age==other.age
# stu1=Student_msg(20)
# stu2=Student_msg(20)
# print(stu1==stu2)


# 封装
# class Phone:
#     __demo=None
#     def __init__(self, name, phone):
#         self.name = name
#         self.phone = phone
#     def __voltage(self):
#         print("我是私有方法")

# 私有方法和属性可以被类的其他成员调用
# class Phone:
#     __Voltage=0.6
#
#     def __Checkvoltage(self):
#         if self.__Voltage<0.5:
#             print("电量过低，转入单核模式运行")
#
#     def fiveG_mode(self):
#         if self.__Voltage>=0.5:
#             print("电量充足，切换到5G模式运行")
#         else:
#             self.__Checkvoltage()
#
# phe1=Phone()
# phe1.fiveG_mode()

#单继承
# class Phone():
#     def call_by_4g(self):
#         print("is calling by 4g")
# class Phone_plus(Phone):
#     def call_by_5g(self):
#         print("is calling by 5g,plus")
#
# phe1=Phone_plus()
# phe1.call_by_5g()
# phe1.call_by_4g()

# 多继承
# class father_class1:
#     def demo1(self):
#         print("father_class1")
# class father_class2:
#     def demo1(self):
#         print("father_class2")
# class father_class3:
#     def demo3(self):
#         print("father_class3")
# class son_class(father_class1,father_class2,father_class3):
#     def call_father_class2_demo1(self):
#         father_class2.demo1(self)
# son1=son_class()
# son1.demo1()
# son1.call_father_class2_demo1()
# son1.demo2()
# son1.demo3()
# son1.demo4()

# 复写
# class father_class1:
#     father_Attribute="父类属性"
#
#     def father_function1(self):
#         print("父类方法")
#
# class son(father_class1):
#     father_Attribute="子类属性"
#
#     def father_function1(self):
#         print("子类方法")
#
# son1=son()
# son1.father_function1()
# print(son1.father_Attribute)

# super关键字
# class father_class1:
#     father_Attribute="父类属性"
#
#     def father_function1(self):
#         print("父类方法")
#
# class son(father_class1):
#     father_Attribute="子类属性"
#
#     def father_function1(self):
#         # 使用父类名.成员名
#         # print(father_class1.father_Attribute)
#         # father_class1.father_function1(self)
#         # 使用super()
#         super().father_function1()
#         print(super().father_Attribute)
#         print("子类方法")
#
# son1=son()
# son1.father_function1()


# 类型注解
# var1 : int
# var1 : int =100
#
# var1=20
# print(var1)
# class student:
#     pass
# stu1: student=student()
# stu = student()
# 方法和返回值的类型注解
# def demo_func(name:str,age:int) -> str:
#     pass
# print(demo_func())
#
# var1: list[Union[int,str]]=list[1,"dsa",2]
# var2 : Union[int,str]="dsa"
#
# var1
# var2
# def demo_func(data:Union[int,str]) -> Union[int,str]:
#     pass


# 多态
# class Father_1:
#     def fa_func01(self):
#         pass
#     def fa_func02(self):
#         pass
# class Son_1(Father_1):
#     def fa_func01(self):
#         print("我是子类方法1")
#     def fa_func02(self):
#         print("我是子类方法2")
# class Son_2(Father_1):
#     def fa_func01(self):
#         print("我是子类方法3")
#     def fa_func02(self):
#         print("我是子类方法4")
#
# son1=Son_1()
#
# son3=Son_2()
#
#
# son1.fa_func01()
# son1.fa_func02()
#
# son3.fa_func01()
# son3.fa_func02()


